<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/3
 * Time: 9:44
 */

namespace app\common\model;


use think\Db;
use think\Model;

class Systems extends Model{

    //获取系统配置的参数
    public function getSystemData($id)
    {
        return $this->where('s_id', $id)
            ->field('s_rmb_dollar_exchange, s_weixin, s_alipay, s_second_level, s_third_level, s_fouth_level, s_service_harge, s_project_num')
            ->select();
    }

    //添加参数
    public function addSystem($params)
    {
        $params['s_create_time'] = time();
        $params['s_update_time'] = time();
        return $this->insert($params);
    }

    //修改参数
    public function updateSystem($params, $id)
    {
        $params['s_update_time'] = time();
        return $this->where('s_id', $id)->update($params);
    }
    /**
     * 获取平台的支付二维码
     */
    public static function getCodePhoto()
    {
        $data = Db::name('systems')->where('s_id', 1)->field('s_weixin, s_alipay')->find();
        $data['s_weixin'] = 'http://'.$_SERVER['HTTP_HOST'].$data['s_weixin'];
        $data['s_alipay'] = 'http://'.$_SERVER['HTTP_HOST'].$data['s_alipay'];
        return $data;
    }

    /**
     * 获取人民币跟美金的兑换比例
     */
    public static function getexchange()
    {
        return Db::name('systems')->where('s_id', 1)->value('s_rmb_dollar_exchange');
    }
}